package com.google.code.bankagregator.vo;

import com.google.code.bankagregator.entities.*;

/**
 * Created with IntelliJ IDEA.
 * User: kirill
 * Date: 01.07.13
 * Time: 0:27
 * To change this template use File | Settings | File Templates.
 */
public class DepositOffer implements Comparable<DepositOffer> {

    private Deposit deposit;


    private double profit = 0.0;


    public DepositOffer(Deposit deposit,int amount) {
        setDeposit(deposit);
        calculateProfit(deposit, amount);
    }

    public void calculateProfit(Deposit deposit, int amount) {
        this.profit = Math.round(((deposit.getDepositRate() * (deposit.getTerm() / 31)) / 12 / 100) * amount);
    }
    public Double getProfit() {
        return profit;
    }

    public String getName() {
        return getDeposit().getName();
    }

    public Currency getCurrency() {
        return getDeposit().getCurrency();
    }

    public Bank getBank() {
        return getDeposit().getBank();
    }

    public Double getDepositRate() {
        return getDeposit().getDepositRate();
    }

    public boolean isRefill() {
        return getDeposit().isRefill();
    }

    public String getUrl() {
        return getDeposit().getUrl();
    }


    public int getMinAmount() {
        return getDeposit().getMinAmount();
    }

    public int getTerm() {
        return getDeposit().getTerm();
    }

    private void setDeposit(Deposit deposit) {
        this.deposit = deposit;
    }

    public Deposit getDeposit() {
        return deposit;
    }



    @Override
    public int compareTo(DepositOffer o) {
            return Double.compare(o.getProfit(),getProfit());
    }

}
